#include <QPushButton>
#include <QMenuBar>
#include <QLineEdit>
#include <QDebug>
#include <QLabel>
#include <alwindow.h>
#include "helper.h"
#include <qfont.h>
#include <writer.h>
#include "mainwindow.h"
#include "levelchoose.h"

levelchoose::levelchoose(QWidget *parent) : QMainWindow(parent) {
    this->setWindowTitle("选择难度");
    this->setFixedSize(800, 600);
    QFont font("等线", 12);
    QFont Menu_font("Microsoft YaHei", 12, 75);
    QMenuBar *bar = menuBar();
    setMenuBar(bar);
    bar->setFont(Menu_font);
    QMenu *startMenu = bar->addMenu("· · ·");
    QAction *help = startMenu->addAction("帮助");
    QAction *back = startMenu->addAction("返回");
    QAction *quit = startMenu->addAction("退出");
    startMenu->addSeparator();
    QAction *shiki = startMenu->addAction("猜猜这是啥");
    connect(help, &QAction::triggered, [=]() {
        helper *helplist = new helper;
        helplist->show();
    });
    connect(back, &QAction::triggered, [=]() {
        this->close();
        MainWindow *window = new MainWindow();
        window->show();
    });
    connect(quit, &QAction::triggered, [=]() {
        this->close();
    });
    connect(shiki, &QAction::triggered, [=]() {
        writer *Easter_egg = new writer;
        Easter_egg->show();
    });
    QPushButton *easy = new QPushButton("简  单", this);
    QPushButton *medium = new QPushButton("中  等", this);
    QPushButton *hard = new QPushButton("困  难", this);
    QPushButton *customize = new QPushButton("自定义", this);
    easy->resize(300, 100);
    easy->setFont(font);
    easy->move(this->width() * 0.5 - easy->width() * 1, this->height() * 0.15);
    medium->resize(300, 100);
    medium->setFont(font);
    medium->move(this->width() * 0.5 - medium->width() * 1, this->height() * 0.35);
    hard->resize(300, 100);
    hard->setFont(font);
    hard->move(this->width() * 0.5 - hard->width() * 1, this->height() * 0.55);
    customize->resize(300, 100);
    customize->setFont(font);
    customize->move(this->width() * 0.5 - customize->width() * 1, this->height() * 0.75);
    connect(easy, &QPushButton::clicked, [=]() {
        len = 9;
        wid = 9;
        num = 10;
        gamescene = new game(nullptr, len, wid, num);
        this->hide();
        gamescene->show();
    });
    connect(medium, &QPushButton::clicked, [=]() {
        len = 16;
        wid = 16;
        num = 40;
        gamescene = new game(nullptr, len, wid, num);
        this->hide();
        gamescene->show();
    });
    connect(hard, &QPushButton::clicked, [=]() {
        len = 30;
        wid = 16;
        num = 99;
        gamescene = new game(nullptr, len, wid, num);
        this->hide();
        gamescene->show();
    });
    //-----打开自选界面-----
    alwindow *op = new alwindow;
    connect(customize, &QPushButton::clicked, [=]() {
        op->show();
    });
    //-----关闭无关界面 打开游戏界面-----
    connect(op, &alwindow::finished, this, [=]() {
        gamescene = new game(nullptr, op->length, op->width, op->num);
        op->close();
        this->hide();
        gamescene->show();
    });
}
